From: Ray Tung Date: Tue, 3 Oct 2017 14:57:49 +0000 (+1100) Subject: Updated old lockfile tests X-Git-Tag: archive/raspbian/0.35.0-2+rpi1~3^2^2^2^2^2^2^2~22^2~6^2~20^2 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/success//%22http:/www.example.com/cgi/success/?a=commitdiff_plain;h=cab464eab79e62c8abbc95fce2f5faa8d07c0194;p=cargo.git Updated old lockfile tests --- diff --git a/tests/lockfile-compat.rs b/tests/lockfile-compat.rs index ffb3900da..d9f679168 100644 --- a/tests/lockfile-compat.rs +++ b/tests/lockfile-compat.rs @@ -8,6 +8,16 @@ use hamcrest::assert_that; #[test] fn oldest_lockfile_still_works() { + let cargo_commands = vec![ + "build", + "update" + ]; + for cargo_command in cargo_commands { + oldest_lockfile_still_works_with_command(cargo_command); + } +} + +fn oldest_lockfile_still_works_with_command(cargo_command: &str) { Package::new("foo", "0.1.0").publish(); let expected_lockfile = @@ -53,24 +63,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "#) .file("src/lib.rs", "") .file("Cargo.lock", old_lockfile); - p.build(); - - let cargo_commands = vec![ - "build", - "update" - ]; - for cargo_command in cargo_commands { - assert_that(p.cargo(cargo_command), - execs().with_status(0)); + p.build(); - let lock = p.read_lockfile(); - for (l, r) in expected_lockfile.lines().zip(lock.lines()) { - assert!(lines_match(l, r), "Lines differ:\n{}\n\n{}", l, r); - } + assert_that(p.cargo(cargo_command), + execs().with_status(0)); - assert_eq!(lock.lines().count(), expected_lockfile.lines().count()); + let lock = p.read_lockfile(); + for (l, r) in expected_lockfile.lines().zip(lock.lines()) { + assert!(lines_match(l, r), "Lines differ:\n{}\n\n{}", l, r); } + + assert_eq!(lock.lines().count(), expected_lockfile.lines().count()); } #[test]